package com.guazai.project.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.system.ApplicationHome;

import java.io.File;

/**
 * @author qiteng
 */
public class AbsolutePathUtils {

    /**
     * 获得绝对路径
     * @param path
     * @return
     */
    public static String getAbsolutePath(String path) {
        //如果参数为空
        if (StringUtils.isBlank(path)) {
            return "";
        }

        ApplicationHome applicationHome = new ApplicationHome(AbsolutePathUtils.class);
        String absolutePath = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + File.separator + path;
        return absolutePath;
    }
}
